Namespace OpenArchive
	Namespace System
        Friend Class Utils
            Friend Shared Function GetAssemblyNameFromFileName(ByVal fileName As String) As String
                If EqualsIgnoreCase(Global.System.IO.Path.GetExtension(fileName), ".dll") Then
                    Return fileName.Substring(0, (fileName.Length - 4))
                End If
                Return fileName
            End Function
            Friend Shared Function EqualsIgnoreCase(ByVal s1 As String, ByVal s2 As String) As Boolean
                If (String.IsNullOrEmpty(s1) AndAlso String.IsNullOrEmpty(s2)) Then
                    Return True
                End If
                If (String.IsNullOrEmpty(s1) OrElse String.IsNullOrEmpty(s2)) Then
                    Return False
                End If
                If (s2.Length <> s1.Length) Then
                    Return False
                End If
                Return (0 = String.Compare(s1, 0, s2, 0, s2.Length, StringComparison.OrdinalIgnoreCase))
            End Function
            Friend Shared Function CheckInterfaceInType(ByVal Typ As Type, ByVal InterfaceType As Type) As Boolean
                If Typ.IsInterface = False And InterfaceType.IsInterface Then
                    Try
                        For Each _implInterface As Type In Typ.GetInterfaces()
                            If Type.Equals(_implInterface, InterfaceType) Then Return True
                        Next

                    Catch ex As Exception
                    End Try
                End If
            End Function
            Friend Shared Function GetTypeByName(ByVal Name As String) As Type
                For Each _asm As Reflection.Assembly In AppDomain.CurrentDomain.GetAssemblies()
                    If Not _asm.GlobalAssemblyCache Then
                        For Each _typ As Type In _asm.GetTypes
                            If Not _typ.IsAbstract Then
                                If _typ.Name = Name Then
                                    Return _typ
                                End If
                            End If
                        Next
                    End If
                Next
                Return Nothing
            End Function
            Friend Shared Function CreateDirectory(ByVal path As String) As Global.System.IO.DirectoryInfo
                Return Global.System.IO.Directory.CreateDirectory(path)
            End Function
            Friend Shared Sub CreateAccessGroup(ByVal Name As String)
                'ToDO
            End Sub
        End Class
	End Namespace
End Namespace


